#include "cvtclass_common.hpp"

void  format_args(char* sbuf, const char* fmt, ...)
{
    char tbuf[maxBuffSize] = { 0 };
    va_list ap;
    va_start(ap, fmt);
    vsnprintf(tbuf, sizeof(tbuf), fmt, ap);
    va_end(ap);
    strcpy(sbuf, tbuf);
}

string xmlErrorInfo(pugi::xml_parse_status xmlStatus)
{
	string statusInfo;
	switch(xmlStatus)
	{
	case pugi::status_file_not_found:
		statusInfo = "file_not_found";
		break;
	case pugi::status_io_error:
		statusInfo = "io_error";
		break;
	case pugi::status_out_of_memory:
		statusInfo = "out_of_memory";
		break;
	case pugi::status_internal_error:
		statusInfo = "internal_error";
		break;
	case pugi::status_unrecognized_tag:
		statusInfo = "unrecognized_tag";
		break;
	case pugi::status_bad_pi:
		statusInfo = "bad_pi:document declaration/processing instruction error";
		break;
	case pugi::status_bad_comment:
		statusInfo = "bad_comment";
		break;
	case pugi::status_bad_cdata:
		statusInfo = "bad_cdata";
		break;
	case pugi::status_bad_doctype:
		statusInfo = "bad_doctype:document type declaration error";
		break;
	case pugi::status_bad_pcdata:
		statusInfo = "bad_pcdata:PCDATA section error";
		break;
	case pugi::status_bad_start_element:
		statusInfo="bad_start_elemen";
		break;
	case pugi::status_bad_attribute:
		statusInfo="bad_attribute:element attribute error";
		break;
	case pugi::status_bad_end_element:
		statusInfo="bad_end_element:end element tag error";
		break;
	case pugi::status_end_element_mismatch:
		statusInfo="end_element_mismatch";
		break;
	case pugi::status_append_invalid_root:
		statusInfo="append_invalid_root";
		break;
	case pugi::status_no_document_element:
		statusInfo="no_document_element";
		break;
	default:
		statusInfo="ok";
	}
	return statusInfo;
}